package l1j.server.server.model.damage.physical;

import l1j.server.server.ActionCodes;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.model.damage.L1DamageOnPc;
import l1j.server.server.model.damage.L1Dmg;
import l1j.server.server.model.damage.L1PcDamage;
import l1j.server.server.serverpackets.S_DoActionGFX;

public class L1PhysicalDamage_Pc_Pc extends L1Dmg {

	private L1PcInstance _attacker;

	private L1PcInstance _target;

	private L1PcDamage _pcDamage;

	public L1PhysicalDamage_Pc_Pc(L1PcInstance attacker, L1PcInstance target) {
		_attacker = attacker;
		_target = target;
		_pcDamage = new L1PcDamage(this, attacker,target);
	}

	public void calcDmg() {
		_pcDamage.calcWeaponDmg(true);
		_pcDamage.calcPcDmg();
		L1DamageOnPc dop = new L1DamageOnPc(this,_target);
		dop.calcDamageOnPc();
		_pcDamage.hitRegenerationHp();
		_pcDamage.effectManaDrain();
		_pcDamage.effectPoision();
		_pcDamage.EffectWeaponMagic();
	}

	@Override
	public void hurtTarget(boolean actionHurt) {
		commitAttacker(_attacker);
		commitTarget(_target);
		_target.receiveDamage(_attacker, getValue());
		if(getValue() > 0 && actionHurt){
			_target.sendPackets(new S_DoActionGFX(
					_target.getId(), ActionCodes.ACTION_Damage));
			_target.broadcastPacket(new S_DoActionGFX(
					_target.getId(), ActionCodes.ACTION_Damage));
		}
	}

}
